<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>shipping detail</title>
  <link rel="stylesheet"  href="../static/layui/css/layui.css">
  <script src="../static/layui/layui.js"></script>
</head>
<body>
<from lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../static/css/form.css">
    <link rel="stylesheet" href="../static/css/index.css">
    <title>货运单详情</title>
    <link rel="stylesheet" href="../../static/css/common.css">
    <link rel="stylesheet" href="../../static/css/form.css">
    <link rel="stylesheet" href="../../static/css/carrierInfo.css">
    <link rel="stylesheet" href="../../static/css/order.css">
    <link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}"/>
    <script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <style type="text/css">
      .box {
        width: 800px;
        margin: 50px auto;
        border: 1px solid #DCDFE6;
        border-radius: 20px;
        padding: 20px;
      }

      .box:hover {
        box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
      }

      .box-title {
        text-align: center;
      }

      .box-table {
        margin-top: 20px;
      }
      .box-nav{
        text-align: center;
      }
    </style>
  </head>
  <body>
  <!-- 菜单栏 -->
  <link rel="stylesheet" href="../../static/css/index.css">
  <ul>
    <div th:each="item:${menuList}" class="display:inline-de">
      <li><a th:href="@{${item.path}}" th:text="${item.name}"></a></li>
    </div>
    <a th:href="@{/login}" style="float:right;font-size: 16px;margin: 17px;color: white;">> 登出</a>
  </ul>
  <div id="content-carrier" class="form-container" style="padding-bottom: 50px;margin-right: auto!important;">
    <h2 class="form-title" style="font-family: 幼圆;font-weight: bold">货运单信息</h2>
    <div class="form">
      <img src="../static/img/truck.png" style="width: 120px;height: 150px;position: relative;left: 10%">
      <form class="form-content" th:object="${shippingOrder}">
        <div class="form-row">
          <label>创建人</label>
          <span th:text="*{creatorName}"/>
        </div>
        <div class="form-row">
          <label>创建时间</label>
          <span th:text="*{time}"/>
        </div>
        <div class="form-row">
          <label>起始点</label>
          <span th:text="*{start}"/>
        </div>
        <div class="form-row">
        <label>目的地</label>
        <span th:text="*{target}"/>
      </div>
        <div style="display:flex;flex-wrap:wrap;">
          <!-- 第一列属性 -->
          <div style="flex-basis:50%;">
            <div class="form-row">
              <label>收货人</label>
              <span th:text="*{consignee}"/>
            </div>
          </div>
          <!-- 第二列属性 -->
          <div style="flex-basis:50%;">
            <div class="form-row">
              <label>状态</label>
              <span th:text="*{state}"/>
            </div>
          </div>
        </div>
        <div class="form-row">
          <label>描述</label>
          <span th:text="*{desc}"/>
        </div>

        <div class="form-row">
          <label>货物</label>
          <span th:text="*{goods}"/>
        </div>
        <div style="display:flex;flex-wrap:wrap;">
        <!-- 第一列属性 -->
        <div style="flex-basis:50%;">
          <div class="form-row">
            <label>重量</label>
            <span th:text="*{weight}"/>
          </div>
          <div class="form-row">
            <label>意外成本</label>
            <span th:text="*{unexpectedCost}"/>
          </div>
        </div>
        <!-- 第二列属性 -->
        <div style="flex-basis:50%;">
          <div class="form-row">
            <label>物流价</label>
            <span th:text="*{logisticsCost}"/>
          </div>
          <div class="form-row">
            <label>总价</label>
            <span th:text="*{totalPrice}"/>
          </div>
        </div>
      </div>
      </form>
    </div>
  </div>
  <div class="box">
    <div class="form-group">
      <h2 class="t2">关联派车单</h2>
      <table class="table table-bordered box-table" style="text-align: center;">
        <tr>
          <th>编号</th>
          <th>货车牌号</th>
          <th>司机名</th>
          <th>货物内容</th>
          <th>重量</th>
          <th>状态</th>
          <th>意外成本</th>
          <th>操作</th>
        </tr>
        <tr th:each="driverTruckOrder : ${shippingOrder.truckOrder}">
          <td th:text="${driverTruckOrder.id}"></td>
          <td th:text="${driverTruckOrder.truck}"></td>
          <td th:text="${driverTruckOrder.driver}"></td>
          <td th:text="${driverTruckOrder.goods}"></td>
          <td th:text="${driverTruckOrder.weight}"></td>
          <td th:text="${driverTruckOrder.state}"></td>
          <td th:text="${driverTruckOrder.unexpectedCost}"></td>
          <td>
            <div class="layui-btn-container">
              <button id="myOperation" th:value="${driverTruckOrder.operationRecord}" class="layui-btn" test-active="detail">详情</button>
            </div>
          </td>
        </tr>
      </table>
    </div>

  </div>
  </form>
  </div>
  </body>
</from>
<script th:inline="javascript">

  layui.use(function(){
    var layer = layui.layer
            ,util = layui.util;

    //触发事件
    util.on('test-active', {
      'detail': function(){
        layer.open({
          type: 1
          ,resize: false
          ,shadeClose: true
          ,area: '800px'
          ,title: '操作记录'
          ,content: ['<table id="table" class="layui-table">'
            ,'<thead>'
            ,'<tr>'
            ,'<th>操作人id</th>'
            ,'<th>操作</th>'
            ,'<th>操作时间</th>'
            ,'<th>到达地点</th>'
            ,'<th>意外信息</th>'
            ,'<th>意外价格</th>'
            ,'</tr>'
            ,'</thead>'
            ,'<tbody >'
            ,'</tbody>'
            ,'</table>'].join('')
          ,success: function(layero, index){
            const records = JSON.parse(document.getElementById('myOperation').value);
            console.log(records)
            for(r in records) {
              $("#table tbody:last").append(
                      "<tr>"
                      +"<td>"+records[r].operatorId+"</td>"
                      +"<td>"+records[r].op+"</td>"
                      +"<td>"+records[r].time+"</td>"
                      +"<td>"+records[r].location+"</td>"
                      +"<td>"+records[r].unexpectedInfo+"</td>"
                      +"<td>"+records[r].unexpectedPrice+"</td>"
                      +"</tr>"
              );
            }

            $("[data-field='type']").children().each(function(){
              if($(this).text()=='1'){
                $(this).text("教务")
              }else if($(this).text()=='2'){
                $(this).text("机构")
              }else if($(this).text()=='3'){
                $(this).text("财务")
              }else if($(this).text()=='4'){
                $(this).text("业务")
              }
            })
            layui.form.render();
            layero.find('.layui-layer-content').css('overflow', 'visible');
          }
        });
      }
    });

  });
</script>
</body>
</html>
